let request = require("request")
let cheerio = require("cheerio")
var iconv = require('iconv-lite'); //引入模块

require("./connect.js")

let {
	Book
} = require("./mod/bookcover.js")
let {
	Chapter
} = require("./mod/chapter.js")


function Request(url, method = "GET", data = {}) {
	return new Promise((res1, rej1) => {
		request({
			url: url,
			method: method,
			data: data,
			encoding: null,
			headers: {
				"content-type": "application/json",
				
			}
		}, (err, res, body) => {
			if (!err && res.statusCode == 200) {
				var buf = iconv.decode(body, 'utf8').toString();  //解码
				res1(buf)
			} else {
				rej1(err)
			}
		})

	})

}


var baseurl = "http://www.shuquge.com/"
//获取当前页的书籍基本信息
async function getPage(baseurl) {

	let data = await Request("http://www.shuquge.com/")

	console.log(data)
	let $ = cheerio.load(data)
}




getPage(baseurl)
